package com.viphuli.app.tool.fragment;

import android.app.Activity;
import android.os.Bundle;
import android.view.MenuItem;

import com.loopj.android.http.RequestParams;
import com.viphuli.app.tool.R;
import com.viphuli.app.tool.common.MyPageHelper;
import com.viphuli.app.tool.handler.MyBaseHttpResponseHandler.HandlerType;
import com.viphuli.app.tool.http.ApiRequest;

public class UpdateUserNameFragment extends UpdateInfoFragment {

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {

		if (R.id.id_menu_update_info_right == item.getItemId()) {

			int userType = args.getInt("user_type", 0);
			String uid = args.getString("uid");

			RequestParams params = new RequestParams();
			params.put("uid", uid);
			params.put("user_name", contentText.getText().toString());
			params.put("user_type", userType);

			ApiRequest.accountChangeUserInfo.request(this, params, HandlerType.waitting);

			return true;
		}

		return false;
	}

	public static void go(Activity act, String title, String content, int userType, String uid) {

		Bundle args = new Bundle();
		args.putString("content", content);
		args.putInt("user_type", userType);
		args.putString("uid", uid);

		MyPageHelper.UpdateUserNameFragment.showMyPage(act, args, title);

	}

}
